package cn.edu.lingnan.user.enums;

public enum QuestionType {
    SINGLE_CHOICE(1, "single_choice"),
    MULTIPLE_CHOICE(2, "multiple_choice"),
    JUDGMENT(3, "judgment"),
    FILL(4, "fill"),
    EXPOUND(5, "expound");

    private final int code;
    private final String description;

    QuestionType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static QuestionType fromCode(int code) {
        for (QuestionType qt : QuestionType.values()) {
            if (qt.getCode() == code) {
                return qt;
            }
        }
        return null;
    }
}
